<?php
if(isset($_POST['ok'])){
	$val=new Helper_Validation;
	$val->check_empty($_POST['txtuser'],ERROR_USER_EMPTY);
	$val->check_empty($_POST['txtpass'],ERROR_PASS_EMPTY);
	$val->check_matches($_POST['txtpass'],$_POST['txtpass2'],ERROR_PASS_MATCHES);
	$val->check_empty($_POST['level'],ERROR_USER_EMPTY);
	if($val->valid() == FALSE){
		$data[error]=$val->_mess;
	}else{
		$muser=new Model_User;
		$data=array(
				"username" => $_POST['txtuser'],
				"password" => $_POST['txtpass'],
				"level"	   => $_POST['level'],
		);
		if($muser->insert_user($data)==TRUE){
			redirect("index.php?module=user&act=list");
		}else{
			$data['error'][]=ERROR_USER_REGISTER;
		}
	}
}
$data['title']="Trang dang ky thanh vien";
loadview("user/add_view",$data);
